<?php

namespace App\Console\Commands;

use App\Models\RechargeOrder;
use App\Models\RechargeOrderDetail;
use App\Models\RechargeTask;
use Illuminate\Console\Command;

class RechargeOrderCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'order:keep {--id=}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $id = $this->option('id');
        if ($id){
            $order = RechargeOrder::where("id",$id)->get();
        }else{
            $order = RechargeOrder::get();
        }
        foreach ($order as $item){
            RechargeOrderDetail::where("recharge_order_id",$item['id'])->update(["recharge_mode"=>$item['recharge_mode']]);
            //RechargeTask::where("recharge_order_id",$item['id'])->update(["recharge_mode"=>$item['recharge_mode']]);
        }
    }
}
